<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <g:set var="entityName" value="${message(code: 'prescription.label', default: 'Prescription')}" />
  <title><g:message code="default.edit.label" args="[entityName]" /></title>
</head>
<body>
  <h1>Selling drugs</h1>
<g:if test="${flash.message}">
  <div class="message">${flash.message}</div>
</g:if>
<g:hasErrors bean="${prescriptionCreatingInstance}">
  <div class="errors">
    <g:renderErrors bean="${prescriptionCreatingInstance}" as="list" />
  </div>
</g:hasErrors>
<div>
  <g:form method="post">
    <table>
      <tbody>
        <tr class="prop">
          <td valign="top" class="name">
            <label for="patient"><g:message code="prescription.patient.label" default="Patient" /></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: prescriptionCreatingInstance, field: 'patient', 'errors')}">
      <g:select name="patient.id" from="${pharmacy.Patient.list()}" optionKey="id" value="${prescriptionCreatingInstance?.patient?.id}"  />
      </td>
      </tr>
      <tr class="prop">
        <td valign="top" class="name">
          <label for="patient"><g:message code="prescription.patient.label" default="Doctor" /></label>
        </td>
        <td valign="top" class="value ${hasErrors(bean: prescriptionCreatingInstance, field: 'doctor', 'errors')}">
      <g:select name="doctor.id" from="${pharmacy.Doctor.list()}" optionKey="id" value="${prescriptionCreatingInstance?.doctor?.id}"  />
      </td>
      </tr>
      <tr class="prop">
        <td valign="top" class="name">
          <label for="date"><g:message code="prescription.date.label" default="Date" /></label>
        </td>
        <td valign="top" class="value ${hasErrors(bean: prescriptionCreatingInstance, field: 'date', 'errors')}">
      <g:datePicker name="date" precision="day" value="${prescriptionCreatingInstance?.date}"  />
      </td>
      </tr>

      <tr class="prop">
        <td valign="top" class="name">
          <label for="quantityAndUses"><g:message code="prescription.quantityAndUses.label" default="Uses" /></label>
        </td>
        <td valign="top" class="value ${hasErrors(bean: prescriptionCreatingInstance, field: 'quantityAndUses', 'errors')}">
          <table>
            <thead>
            <th>Medicine name</th><th>Quantity</th><th>Unit</th><th>Uses</th>
            </thead>
            <tbody>
              <tr><td>
            <g:select name="drugInPrescriptionInstance.drug.id" from="${pharmacy.Drug.list()}" optionKey="id"/>
        </td>
        <td>
      <g:textField name="drugInPrescriptionInstance.quantity"  />
      </td>
      <td>
      <g:select name="drugInPrescriptionInstance.unit" />
      </td>
      <td>
      <g:textField name="drugInPrescriptionInstance.uses"  />
      </td>
      </tr>
      </tbody>
    </table>

    </td>
    </tr>



    </tbody>
    </table>
</div>
<div class="buttons">
  <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
  <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
</div>

</g:form>
</body>

</html>
